<? $venta= new Venta();
/*estado: 0:pedido  1:presupuesto   2:factura   */
$venta->estado=1;
$venta->save();
Session::set_data('pedido', $venta->id);
Session::set_data('estado', $venta->estado);//guardo el estado para cuando imprima coloque si es pedido, presupuesto o factura automaticamente

?>

<link href='../../insumos/Scripts/styles.css' rel='stylesheet' type='text/css' />

<br>
</div>
<? if(($_SESSION['rol']=='F')OR ($_SESSION['rol']=='G') OR ($_SESSION['rol']=='A'))
{
?>
<?
}
 ?>
<?php echo form_remote_tag("venta/agregar_producto_presupuesto","update: midiv5") ?>

<table width="70%" height="161" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#EFEFEF" class="texto">
 <tr>
    <td height="30" background="/insumos/img/fondo1.jpg" class="texto">
      <div align="center"><strong>Cliente: </strong>
        <select name="select" id='cliente_id' tabindex="1">
          <option >Seleccione un...</option>
          <? foreach($Cliente->find("order: nombre asc") as $cliente): ?>
          <option value='<?php echo $cliente->id; ?>'> <?php echo $cliente->nombre; ?></option>
          <? endforeach; ?>
        </select>
    </div>      </td>
    
    <td background="/insumos/img/fondo1.jpg" class="texto"><div id='div_cliente' class="texto"></div></td>
    
   
  </tr>
   <tr>
    <td  colspan="4" class="texto">&nbsp;</td>
  </tr>
  <tr>
      <td background="/insumos/img/fondo1.jpg" class="texto">
	<div class="texto" align="center"> <strong>Rubro:</strong>
    <select name="select2" id='rubro_id' tabindex="2" >
            <option>Seleccione un...</option>
            <? foreach($Rubro->find("order: nombre asc") as $rubro): ?>
            <option value='<?php echo $rubro->id; ?>'> <?php echo $rubro->nombre; ?></option>
            <? endforeach; ?>
        </select>
    </div>	</td>
    </tr>
    <tr>
    <td background="/insumos/img/fondo1.jpg" class="texto"><div id='div_producto' class="texto" align="center"></div></td>
  </tr> 
  <tr>
    <td><br>
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td bgcolor="#FFFFFF"><div align="right"><strong>C&oacute;digo de Producto a agregar:&nbsp;</strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo text_field_tag("cod_prod") ?></td>
            <td>&nbsp;</td>
            <td height="30" bgcolor="#FFFFFF"><div align="right"><strong>Cantidad:&nbsp;</strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo text_field_tag("cant_prod") ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td bgcolor="#FFFFFF"><div align="right"><strong>Lista de Precios:&nbsp;</strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo select_tag("lista", array("0" => "Por Defecto","4" => "Lista 4","2" => "lista 2","5" => "Lista 5"))?></td>
            <td>&nbsp;</td>
            <td height="30" bgcolor="#FFFFFF"><div align="right"><strong>Descuento: &nbsp;</strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo numeric_field_tag("descuento", "size: 5") ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td height="30" bgcolor="#FFFFFF"><div align="right"><strong>Precio $:&nbsp; </strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo numeric_field_tag("precio", "size: 10") ?></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
      </table></td>
  </tr>
  </tr>
  
  <tr>
    <td bgcolor="#006699"><div align="center"><?php echo submit_tag("Agregar", "onclick: return seleccionaFoco2();") ?></div>
</table>
<?php echo end_form_tag() ?><?php echo form_remote_tag("venta/producto_comodin","update: midiv5") 
//ACA voy a poner el producto comod&iacute;n
?><br>
<table width="70%" height="132" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E1E1E1" class="texto">
  <tr>
    <td>
        <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="30" bgcolor="#FFFFFF"><div align="right"><strong>Producto extra a agregar:&nbsp;&nbsp;</strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo text_field_tag("comodin") ?></td>
            <td>&nbsp;</td>
            <td bgcolor="#FFFFFF"><div align="right"><strong>Cantidad:&nbsp;</strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo text_field_tag("cant_comodin") ?></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td height="30" bgcolor="#FFFFFF"><div align="right"><strong>Precio $:&nbsp; </strong></div></td>
            <td bgcolor="#FFFFFF"><?php echo numeric_field_tag("precio_comodin", "size: 10") ?></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
    </td>
  </tr>
  </tr>
  
  <tr>
    <td bgcolor="#006699"><div align="center"><?php echo submit_tag("Agregar Extra") ?></div>
</table>

<?php echo end_form_tag() ?> <br>
<br>
<div align="center">
</div>
<table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#E1E1E1" class="texto">
<tr>
		<td height="30"><div align="right"><strong>C&oacute;digo de Producto a borrar:&nbsp;</strong></div></td>
	<td><?php echo form_remote_tag("venta/borrar","update: midiv5") ?>
	<?php echo text_field_tag("cod_prod_borrar"); ?></td>
		<td><div align="left">
	    <?php echo submit_tag("Quitar"); ?></div></td>
		<?php echo end_form_tag(); ?>

</tr>
</table>
<div id='midiv7'>
</div>		
<div align="center">
  </h3>
  <?
echo "<form TARGET='_blanc', action=\"imprimir" .  "\" method=\"POST\">\n\n"; 
   echo "<input type='submit' name='submit' value='Generar Impresi&oacute;n'>"; 
   echo "</form>";
?>
 <?
echo "<form TARGET='_blanc', action=\"confirmar" .  "\" method=\"POST\">\n\n"; 
   echo "<input type='submit' name='submit' value='Confirmar'>"; 
   echo "</form>";
?>
   <?
echo "<form TARGET='_blanc', action=\"facturar_presupuesto_directo" .  "\" method=\"POST\">\n\n"; 
   echo "<input type='submit' name='submit' value='Facturar'>"; 
   echo "</form>";
?>
</div>

  <script type="text/javascript">
 new Event.observe("rubro_id", "change", function(){
 new AJAX.viewRequest({
 action: "venta/obtener_productos/"+$F("rubro_id"),
 container: "div_producto"
 })
 })
  </script>
<script type="text/javascript">
 new Event.observe("cliente_id", "change", function(){
 new AJAX.viewRequest({
 action: "venta/asignar_cliente/"+$F("cliente_id"),
 container: "div_cliente"
 })
 })
</script>
 </div>
 <div id='midiv5'>
</div>
<div id='midiv6'> </div>



<html>
<head>
	<title>Seleccionar y foco</title>
 <script>
 function seleccionaFoco(){
	document.formulario.cod_prod.focus()//ESTO ES PARA HACER FOCO EN EL TEXT BOX DEL CODIGO DE PRODUCTO
	document.formulario.cod_prod.select()
 
 }
 </script>
  <script>
 function seleccionaFoco2(){
	//document.select2.focus()
	//document.select2.select()
 document.getElementById("rubro_id").focus();

 }
 </script>
</head>
 